using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Tongdao : MonoBehaviour
{
    public Sprite tongdaoOpenSprite;
    public BoxCollider2D trigger;
    
    SpriteRenderer spriteRenderer;

    // Start is called before the first frame update
    void Start()
    {
        spriteRenderer = GetComponent<SpriteRenderer>();
        trigger.enabled = false;
    }

    void OnEnable(){
        EventHandler_Prop.FishInCaseStopEvent += OnFishInCaseStopEvent;
    }

    void OnDisable(){
        EventHandler_Prop.FishInCaseStopEvent -= OnFishInCaseStopEvent;
    }

    public void OnFishInCaseStopEvent(){
        spriteRenderer.sprite = tongdaoOpenSprite;
        trigger.enabled = true;        
    }


    public void OnTriggerEnter2D(Collider2D other){
        Unit_Charactor_Ctrl unit_Charactor_Ctrl = other.gameObject.GetComponentInParent<Unit_Charactor_Ctrl>();
        if(unit_Charactor_Ctrl != null){
            unit_Charactor_Ctrl.moveLocks.Add("to_finish");
            UIManager.instance.SwtichMaskPerformance(true, 1, () =>
            {
                LoadScene_Manager.instance.LoadScene("Finish");
            });
        }
        
    }

}
